#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int game(int*p1,int len,int*p2)
{
	int count = 0;
	for (int i = 0; i < len; i++)
	{
		if (*p1 == *p2)
		{
			p1++;
			p2++;
			count++;
		}
	}
	return count;
}
int main()
{
	int arr1[3] = { 0 }, arr2[3] = { 0 };
	for (int i = 0; i < 3; i++)
	{
		scanf("%d%d", &arr1[i], &arr2[i]);
	}
	printf("%d", game(arr1, 3, arr2));
	return 0;
}